package com.jiazhong.cloud.example.student.course.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jiazhong.cloud.example.student.commons.bean.Course;
import com.jiazhong.cloud.example.student.commons.mapper.CourseMapper;
import com.jiazhong.cloud.example.student.commons.util.JsonResult;
import com.jiazhong.cloud.example.student.commons.util.ResultTool;
import com.jiazhong.cloud.example.student.course.service.CourseService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {

    @Override
    public JsonResult saveCourse(Course course) {
        save(course);
        return ResultTool.success("success");
    }

    @Cacheable(cacheNames = "findCourseById")
    public JsonResult findCourseById(String id) {
        return ResultTool.success(getById(id));
    }
}
